cmake_minimum_required(VERSION 3.5)
project(uav_swarms)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Ofast -DNDEBUG -Wno-deprecated-declarations")

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(std_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(mavros_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(tf2_geometry_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(yolo_detect_message REQUIRED)
find_package(geographic_msgs REQUIRED)

find_package(GeographicLib REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()
include_directories(
  include
  ${jsoncpp_INCLUDE_DIRS}
  "/usr/include/eigen3"
)
add_executable(CoordinateConform_node
  src/CoordinateConform_node.cpp)
target_link_libraries(CoordinateConform_node
  jsoncpp_lib)
ament_target_dependencies(CoordinateConform_node 
  geometry_msgs
  rclcpp
  tf2_ros
  std_msgs
  mavros_msgs
  geographic_msgs
)

add_executable(getlocalpos_node
  src/getlocalpos_node.cpp)


ament_target_dependencies(getlocalpos_node 
  geometry_msgs
  rclcpp
  std_msgs
  tf2
  yolo_detect_message
  tf2_ros
  tf2_geometry_msgs
  mavros_msgs
  geographic_msgs
) 
target_link_libraries(getlocalpos_node
  ${GeographicLib_LIBRARIES})

  
add_executable(Follow_node
  src/Follow_node.cpp  src/Follower.cpp)


ament_target_dependencies(Follow_node 
  geometry_msgs
  rclcpp
  std_msgs
  tf2
  yolo_detect_message
  mavros_msgs
  tf2_ros
  geographic_msgs
  tf2_geometry_msgs
) 






add_executable(avoid_node
  src/avoid.cpp   src/avoid_node.cpp )


ament_target_dependencies(avoid_node 
  geometry_msgs
  rclcpp
  std_msgs
  tf2
  tf2_ros
  tf2_geometry_msgs
  geographic_msgs
  mavros_msgs
) 

add_executable(leader_node
  src/leader.cpp   src/leader_node.cpp )


ament_target_dependencies(leader_node 
  geometry_msgs
  rclcpp
  std_msgs
  tf2
  yolo_detect_message
  tf2_ros
  mavros_msgs
  tf2_geometry_msgs
  geographic_msgs
) 

add_executable(communication_multirotor_node
  src/communication_multirotor.cpp   src/communication_multirotor_node.cpp )


ament_target_dependencies(communication_multirotor_node 
  geometry_msgs
  rclcpp
  std_msgs
  yolo_detect_message
  geographic_msgs
  tf2
  tf2_ros
  tf2_geometry_msgs
  mavros_msgs
) 


install(TARGETS CoordinateConform_node getlocalpos_node  avoid_node communication_multirotor_node Follow_node leader_node
  DESTINATION lib/${PROJECT_NAME})


install(DIRECTORY launch config  DESTINATION share/${PROJECT_NAME})
ament_package()
